1. /* sdfexbsr.cpp by K.Tsuru */
  2. /***********************************************************************
  3. It evaluates exp(n/d) with ExpBSRType n and d using binary splitting method.
  4. ************************************************************************/
  5. #ifndef SN_H
  6. #include "sn.h"
  7. #endif
  8. static const char* const func = "ExpBSR()";
  9. typedef SLong ExpBSRType; // SLong version exp(sqrt(2.0)) 3.6(sec) in 40,000 decimals
  10. // typedef SDouble ExpBSRType; // SDouble version 4.2 (sec)
  11. /******************************************************
  12. It returns the value exp(n/d) as a rational number a/c.
  13. ******************************************************/
  14. // function ID = 3317 ver. 2.18
  15. static SDouble C;
  16. void ExpBSR(const SLong& n, const SLong& d, SLong& a, SLong& c) {
  17. long prec = long(C.EffFig() + C.Hidden()) * DFIGURES;
  18. double log10x = n.DFigures() - d.DFigures();
  19. if(log10x > 0) C.SetError(C.SYNTAX_ERR, func, 3317);
  20. long L = upToExpSeries(prec, log10x + 1);
  21. ExpBSRationalNumber<ExpBSRType> expX(L, prec, n, d); // defined in "sbstempl.h"
  22. expX.putTogether();
  23. a = expX.getA(); c = expX.getC(); // expX.getAC(a, c);
  24. }
  25. /**********************************************************
  26. It evaluates exp(n/d). Condition n < d must be satisfied.
  27. ******************************************************/
  28. // function ID = 3316 ver. 2.18
  29. SDouble ExpBSR(const SLong& n, const SLong& d) {
  30. SLong a, c;
  31. ExpBSR(n, d, a, c);
  32. return SDouble(a) / SDouble(c);
  33. }

sdfexbsr.cpp : last modifiled at 2015/05/24 15:45:43(1,497 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).